﻿using System.ComponentModel;

namespace com.yoozoo.gta.Extension.UGUI.Editor
{
    using UnityEditor;
    using UnityEngine;

    [CustomPropertyDrawer(typeof(ReadOnlyAdapterAttribute))] 
    public class ReadOnlyAdapterDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (EditorApplication.isPlaying  || !EditorPrefs.GetBool("ScreenOrientManager_InspectorEditMode", false))
            {
                GUI.enabled = false;
                EditorGUI.PropertyField(position, property, label, true);
                GUI.enabled = true;
            }
            else
            {
                    GUI.enabled = true;
                    EditorGUI.PropertyField(position, property, label, true);
                    GUI.enabled = true;     
            }
           
        }
    }
}